package com.ckzp.jfinal.weixin.controller;

import com.ckzp.jfinal.base.BaseController;
import com.ckzp.jfinal.base.PageSearch;
import com.ckzp.jfinal.form.FormData;
import com.ckzp.jfinal.interceptor.Admins;
import com.ckzp.jfinal.system.model.SysWorklog;
import com.ckzp.jfinal.weixin.model.WxMember;
import com.ckzp.plugins.layui.LayuiData;
import com.jfinal.plugin.activerecord.Page;

import java.util.List;

/**
 * Created by 51594 on 2021/6/4.
 */
public class WxMemberController extends BaseController {

    @Admins(roles = "system", name = "默认", log = false)
    public void index() {
        renderText("默认");
    }


    /**
     * 列表
     */
    @Admins(roles = "system", name = "列表PAGE", log = false)
    public void WxMemberList() {
        FormData fd = FormData.dao();
        setAttr("form", fd);
        render("WxMemberList.html");
    }

    /**
     * 微信用户数据查询API
     */
    @Admins(roles = "system", name = "微信用户数据查询API", log = false)
    public void WxMemberListDataApi() {

        PageSearch ps = PageSearch.n().setTable("wx_member").orderby("open_id desc")
                .initSearch(getRequest());
        Page<WxMember> pages = ps.paginate(WxMember.dao);

        List<WxMember> datalist = pages.getList();
        for (WxMember user : datalist) {
        }
        renderJson(LayuiData.newData().setData(datalist).setCount(pages.getTotalRow()));
    }
}

